package com.itheima.pay.controller;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeFastpayRefundQueryRequest;
import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse;
import com.alipay.api.response.AlipayTradePrecreateResponse;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.alipay.api.response.AlipayTradeRefundResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Description:
 * @Version: V1.0
 */
@RestController
@RequestMapping("pay")
public class PayController {

  // 生成交易二维码
  @GetMapping("precreate/{orderNo}")
  public void precerate(@PathVariable Long orderNo) throws AlipayApiException {
    AlipayClient alipayClient = new DefaultAlipayClient(
            "https://openapi.alipaydev.com/gateway.do",
            "2021000121643172",
            "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDQ+ejvFsZdax6M5RXOjKUD51EqHitRwNMa0SvVxdmKILMTi5G5naCBlr+QXktPCQ1o6W+ieenj4xmo3nzNAlUq7v+BbGiD4DYmMUFxAaX6rNVToeo666qR3V582iAfCAIAegxtcf/N1UTiA4NqVqez/2kwfKFN1xoQltfTDvH8LrYUxJMrkupEdf1pdZvCUyo7ZcCNobaJnlYjJB2e29AQeQ/MfvOz+IIE040K7zU62fLBEGkFvpa2RLIgAZozduitr9jxUs61hMHRL/QkYqf0EVb9ZqOWM3qq4zGEOrsya7HRbw50j6PKx309sxRjenchZyctGXEs26IeiowZ7k8PAgMBAAECggEBAL5FfTAMBYrTWJqijstkxW6bdAwsMfca4Vt+bjITFbIteb9nCcT+X0D+l+cD4//PVzVZrjo6VJoYkalvAiTL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UJA+p6lz1T2u0GaCUVF9/S9wtghlieMHLZfPAZJNL7r6HGHMnTHjT7H+0wdz2zeuA==",
            "json",
            "GBK",
            "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj5087MsImIQt20UhJwVGak4cM48NWHKZbNCCy5RS0emNiMsfonePRrQH322rAfdeGxcSGjMz6ZlNFWK8Sya1+cM9ftNzzegsPObsrv5UQbWLAD+FobrWkWh95ggxgLtOEWX3rXADRzjQKaxm3t4XqiaRhYbZSbc0iyT4gVoSC9yLpqw62QLjbzdv+eHpcY4PA+xtUBVqDZTq8JOUm+ePvwqJmkq/w/SwQqEe9o53rpePc3sZNT2O3v55sd/+PO/SvExKp0I1bnnfOp7LObRUDf7vZt1c95XofYih9gjBC73MibtZwdbzRHFtJbdpE5hzCIK/UnQD3Gm2Xftb3dCaxwIDAQAB",
            "RSA2");
    AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
    request.setNotifyUrl("");
    JSONObject bizContent = new JSONObject();
    bizContent.put("out_trade_no", orderNo);
    bizContent.put("total_amount", 10000);
    bizContent.put("subject", "空气");

//// 商品明细信息，按需传入
//JSONArray goodsDetail = new JSONArray();
//JSONObject goods1 = new JSONObject();
//goods1.put("goods_id", "goodsNo1");
//goods1.put("goods_name", "子商品1");
//goods1.put("quantity", 1);
//goods1.put("price", 0.01);
//goodsDetail.add(goods1);
//bizContent.put("goods_detail", goodsDetail);

//// 扩展信息，按需传入
//JSONObject extendParams = new JSONObject();
//extendParams.put("sys_service_provider_id", "2088511833207846");
//bizContent.put("extend_params", extendParams);

//// 结算信息，按需传入
//JSONObject settleInfo = new JSONObject();
//JSONArray settleDetailInfos = new JSONArray();
//JSONObject settleDetail = new JSONObject();
//settleDetail.put("trans_in_type", "defaultSettle");
//settleDetail.put("amount", 0.01);
//settleDetailInfos.add(settleDetail);
//settleInfo.put("settle_detail_infos", settleDetailInfos);
//bizContent.put("settle_info", settleInfo);

//// 二级商户信息，按需传入
//JSONObject subMerchant = new JSONObject();
//subMerchant.put("merchant_id", "2088000603999128");
//bizContent.put("sub_merchant", subMerchant);

//// 业务参数信息，按需传入
//JSONObject businessParams = new JSONObject();
//businessParams.put("busi_params_key", "busiParamsValue");
//bizContent.put("business_params", businessParams);

//// 营销信息，按需传入
//JSONObject promoParams = new JSONObject();
//promoParams.put("promo_params_key", "promoParamsValue");
//bizContent.put("promo_params", promoParams);

    request.setBizContent(bizContent.toString());
    AlipayTradePrecreateResponse response = alipayClient.execute(request);
    String qrCode = response.getQrCode();

    if (response.isSuccess()) {
      System.out.println("调用成功");
      System.out.println(qrCode);
    } else {
      System.out.println("调用失败");
    }
  }

  @GetMapping("query/{orderNo}")
  public AlipayTradeQueryResponse query(@PathVariable Long orderNo) throws Exception {
    AlipayClient alipayClient = new DefaultAlipayClient(
            "https://openapi.alipaydev.com/gateway.do",
            "2021000121643172",
            "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDQ+ejvFsZdax6M5RXOjKUD51EqHitRwNMa0SvVxdmKILMTi5G5naCBlr+QXktPCQ1o6W+ieenj4xmo3nzNAlUq7v+BbGiD4DYmMUFxAaX6rNVToeo666qR3V582iAfCAIAegxtcf/N1UTiA4NqVqez/2kwfKFN1xoQltfTDvH8LrYUxJMrkupEdf1pdZvCUyo7ZcCNobaJnlYjJB2e29AQeQ/MfvOz+IIE040K7zU62fLBEGkFvpa2RLIgAZozduitr9jxUs61hMHRL/QkYqf0EVb9ZqOWM3qq4zGEOrsya7HRbw50j6PKx309sxRjenchZyctGXEs26IeiowZ7k8PAgMBAAECggEBAL5FfTAMBYrTWJqijstkxW6bdAwsMfca4Vt+bjITFbIteb9nCcT+X0D+l+cD4//PVzVZrjo6VJoYkalvAiTLZe5Uc7FMmpDQWZ1GpbYV8SEfspCWUSVapBBxhXGaTTrT2LbEaYJRFL892p0K4+GzirhZ6lWqdFfibSoDnfjel7eqzl/lcv41w1Z1Y6U4TLobIQnvb1EMBTSWz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gKCAQEAj5087MsImIQt20UhJwVGak4cM48NWHKZbNCCy5RS0emNiMsfonePRrQH322rAfdeGxcSGjMz6ZlNFWK8Sya1+cM9ftNzzegsPObsrv5UQbWLAD+FobrWkWh95ggxgLtOEWX3rXADRzjQKaxm3t4XqiaRhYbZSbc0iyT4gVoSC9yLpqw62QLjbzdv+eHpcY4PA+xtUBVqDZTq8JOUm+ePvwqJmkq/w/SwQqEe9o53rpePc3sZNT2O3v55sd/+PO/SvExKp0I1bnnfOp7LObRUDf7vZt1c95XofYih9gjBC73MibtZwdbzRHFtJbdpE5hzCIK/UnQD3Gm2Xftb3dCaxwIDAQAB",
            "RSA2");
    AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
    JSONObject bizContent = new JSONObject();
    bizContent.put("out_trade_no", orderNo);
    request.setBizContent(bizContent.toString());
    AlipayTradeQueryResponse response = alipayClient.execute(request);
    if (response.isSuccess()) {
      System.out.println("调用成功");
      String tradeStatus = response.getTradeStatus();
      System.out.println(tradeStatus);
      if ("TRADE_SUCCESS".equals(tradeStatus)) {
        System.out.println("支付成功");
        return response;
      } else {
        System.out.println("支付失败");
        return response;
      }

    } else {
      System.out.println("调用失败");
    }
  return null;
  }

  @GetMapping("refund/{orderNo}/{amount}/{no}")
  public AlipayTradeRefundResponse refund(@PathVariable Long orderNo, @PathVariable String amount, @PathVariable String no) throws Exception {
    AlipayClient alipayClient = new DefaultAlipayClient(
            "https://openapi.alipaydev.com/gateway.do",
            "2021000121643172",
            "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDQ+ejvFsZdax6M5RXOjKUD51EqHitRwNMa0SvVxdmKILMTi5G5naCBlr+QXktPCQ1o6W+ieenj4xmo3nzNAlUq7v+BbGiD4DYmMUFxAaX6rNVToeo666qR3V582iAfCAIAegxtcf/N1UTiA4NqVqez/2kwfKFN1xoQltfTDvH8LrYUxJMrkupEdf1pdZvCUyo7ZcCNobaJnlYjJB2e29AQeQ/MfvOz+I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V4jo1vRWXEehQ6MAzbgbjz6GQ77CHimXBM13z0nHoZjtpYMZa/cyYL890lG1/A1MN4A7/+tTr6/lCy5Bl7MIluOLnyQKBgQCO5EnDQO/vE5QVZqF2H9g+UpK4eIktG4+MJQuBYXIayCT3Y//sMb6vaxDAAo6cA6Fvr2Jnev/uuacduhpoY129e80WOVm0uzzCgB9R1gZj1UJA+p6lz1T2u0GaCUVF9/S9wtghlieMHLZfPAZJNL7r6HGHMnTHjT7H+0wdz2zeuA==",
            "json",
            "GBK",
            "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj5087MsImIQt20UhJwVGak4cM48NWHKZbNCCy5RS0emNiMsfonePRrQH322rAfdeGxcSGjMz6ZlNFWK8Sya1+cM9ftNzzegsPObsrv5UQbWLAD+FobrWkWh95ggxgLtOEWX3rXADRzjQKaxm3t4XqiaRhYbZSbc0iyT4gVoSC9yLpqw62QLjbzdv+eHpcY4PA+xtUBVqDZTq8JOUm+ePvwqJmkq/w/SwQqEe9o53rpePc3sZNT2O3v55sd/+PO/SvExKp0I1bnnfOp7LObRUDf7vZt1c95XofYih9gjBC73MibtZwdbzRHFtJbdpE5hzCIK/UnQD3Gm2Xftb3dCaxwIDAQAB",
            "RSA2");
    AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
    JSONObject bizContent = new JSONObject();
    bizContent.put("out_trade_no", orderNo);
    bizContent.put("refund_amount", amount);
    bizContent.put("out_request_no", no);
    request.setBizContent(bizContent.toString());
    AlipayTradeRefundResponse response = alipayClient.execute(request);
    if (response.isSuccess()) {
      System.out.println("调用成功");
      String fundChange = response.getFundChange();
      String refundFee = response.getRefundFee();
      String tradeNo = response.getTradeNo();
      if ("Y".equals(fundChange)) {
        System.out.println("成功退款:"+refundFee+"退款单号:"+tradeNo);
        return response;
      }
    } else {
      System.out.println("调用失败");
      return response;
    }
    return null;
  }
    @GetMapping("fastpay/{orderNo}/{no}")
    public AlipayTradeFastpayRefundQueryResponse fastpay(@PathVariable Long orderNo,@PathVariable String no) throws Exception {
      AlipayClient alipayClient = new DefaultAlipayClient(
              "https://openapi.alipaydev.com/gateway.do",
              "2021000121643172",
              "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDQ+ejvFsZdax6M5RXOjKUD51EqHitRwNMa0SvVxdmKILMTi5G5naCBlr+QXktPCQ1o6W+ieenj4xmo3nzNAlUq7v+BbGiD4DYmMUFxAaX6rNVToeo666qR3V582iAfCAIAegxtcf/N1UTiA4NqVqez/2kwfKFN1xoQltfTDvH8LrYUxJMrkupEdf1pdZvCUyo7ZcCNobaJnlYjJB2e29AQeQ/MfvOz+IIE040K7zU62fLBEGkFvpa2RLIgAZozduitr9jxUs61hMHRL/QkYqf0EVb9ZqOWM3qq4zGEOrsya7HRbw50j6PKx309sxRjenchZyctGXEs26IeiowZ7k8PAgMBAAECggEBAL5FfTAMBYrTWJqijstkxW6bdAwsMfca4Vt+bjITFbIteb9nCcT+X0D+l+cD4//PVzVZrjo6VJoYkalvAiTLZe5Uc7FMmpDQWZ1GpbYV8SEfspCWUSVapBBxhXGaTTrT2LbEaYJRFL892p0K4+GzirhZ6lWqdFfibSoDnfjel7eqzl/lcv41w1Z1Y6U4TLobIQnvb1EMBTSWzdZZRyK1eREFPUQv32om4/sahDpHBExwNkusfHerCKhxVtUDDJgGrNF9Oo1CuJd3mdlY9DgW3C0DJZYX/ZVshqzVhxuSYKCkW5ViFZ+P6QWeEfa3e86gN4tG+Gf29PIRtmrTfb8CAokCgYEA9Nqxqg9Buileho6svEJdVw0P9ar5FnMLJNwGrWii77GNxR/OiL8DjdDbRNsOb3MI9XnCiWpf6gQBJXZ+jHD/OgvMdjOKWqEPrgR/0asK30Pu2y2GDnWosg5tRLz9x+J75Cqhc/7Q97UZpbpkueDzZZkyQBHZrkJ7MRb4NRrxN+sCgYEA2n0gQxt/rsKI4jSZnM6c6hTuTa7DWiayjU0+xElnwZ7wuMsaCRJefN34iJ9OXPBt7hQxGTpRuszqH6Ac1UMEhFWtVEFsDUtxop/h0jv/Q2aiPjMV4YZqoezLKaWnAv4pVXVsqYQHY3De+HrK22DPltJnPsba67t4ICYJY+LMgG0CgYEAvF8fPbjdFQ5MlXJgO7lGu/jlpVdyqC27jhDj5jbQ21yat+O/bf6eClV6y19HnMBATTHuUu+OeKe6BgtCUmOARzTaiLkgIJc2S+dUOoa/J4LI2MAOGUO1k757m91V1JhOPfv6GBYax+cAozph0YrZVflk6luRP3oP8nU8YQaoOx8CgYBSwI2VnTaxBDFAK9f6ki7QYfkYJxcKcBm0dwtM4NiRdxeJhjNoODLdbF0TsfLGNLIOOEuYWIRYEgCi1cvV4jo1vRWXEehQ6MAzbgbjz6GQ77CHimXBM13z0nHoZjtpYMZa/cyYL890lG1/A1MN4A7/+tTr6/lCy5Bl7MIluOLnyQKBgQCO5EnDQO/vE5QVZqF2H9g+UpK4eIktG4+MJQuBYXIayCT3Y//sMb6vaxDAAo6cA6Fvr2Jnev/uuacduhpoY129e80WOVm0uzzCgB9R1gZj1UJA+p6lz1T2u0GaCUVF9/S9wtghlieMHLZfPAZJNL7r6HGHMnTHjT7H+0wdz2zeuA==",
              "json",
              "GBK",
              "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj5087MsImIQt20UhJwVGak4cM48NWHKZbNCCy5RS0emNiMsfonePRrQH322rAfdeGxcSGjMz6ZlNFWK8Sya1+cM9ftNzzegsPObsrv5UQbWLAD+FobrWkWh95ggxgLtOEWX3rXADRzjQKaxm3t4XqiaRhYbZSbc0iyT4gVoSC9yLpqw62QLjbzdv+eHpcY4PA+xtUBVqDZTq8JOUm+ePvwqJmkq/w/SwQqEe9o53rpePc3sZNT2O3v55sd/+PO/SvExKp0I1bnnfOp7LObRUDf7vZt1c95XofYih9gjBC73MibtZwdbzRHFtJbdpE5hzCIK/UnQD3Gm2Xftb3dCaxwIDAQAB",
              "RSA2");
      AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();
      JSONObject bizContent = new JSONObject();
      bizContent.put("out_trade_no", orderNo);
      bizContent.put("out_request_no", no);
      request.setBizContent(bizContent.toString());
      AlipayTradeFastpayRefundQueryResponse response = alipayClient.execute(request);
      if(response.isSuccess()){
        String refundStatus = response.getRefundStatus();
        if (refundStatus.equals("REFUND_SUCCESS")) {
          System.out.println("退款成功");
          return response;
        }

        System.out.println("调用成功");
      } else {
        System.out.println("调用失败");
      }
  return null;
    }

}